package com.ybkj.o2o.zhuanxian.manager.impl;

import com.ybkj.o2o.zhuanxian.common.DataGrid;
import com.ybkj.o2o.zhuanxian.entity.OrderRefuse;
import com.ybkj.o2o.zhuanxian.manager.OrderRefuseManager;
import com.ybkj.o2o.zhuanxian.service.OrderRefuseService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class DefaultOrderRefuseManager implements OrderRefuseManager {

  @Autowired
  private OrderRefuseService orderRefuseService;

  @Override
  public DataGrid<OrderRefuse> findByParams(Long companyId, String orderNo, String employName,
      Date start, Date end, Integer page, Integer rows, String appKey) {
    Integer limit = null;
    if (page != null && rows != null) {
      limit = (page - 1) * rows;
    }
    List<OrderRefuse> list =
        orderRefuseService.findByParams(companyId, orderNo, employName, start, end, limit, rows,
            appKey);
    Long total =
        orderRefuseService.countByParam(companyId, orderNo, employName, start, end, appKey);
    DataGrid<OrderRefuse> data = new DataGrid<OrderRefuse>();
    data.setRows(list);
    data.setTotal(total);
    return data;
  }
}
